﻿/*
	Copyright (c) 2013 Andrew Meyer

	Permission is hereby granted, free of charge, to any person obtaining a copy of this software
	and associated documentation files (the "Software"), to deal in the Software without
	restriction, including without limitation the right to use, copy, modify, merge, publish,
	distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
	Software is furnished to do so, subject to the following conditions:

	The above copyright notice and this permission notice shall be included in all copies or
	substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
	BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
	NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
	DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace Ascend
{
	/// <summary>
	/// Class that defines how vertices are affected by an Ascend.Bone. This class cannot be
	/// inherited.
	/// </summary>
	public sealed class VertexInfluence
	{
		#region Lifecycle
		/// <summary>
		/// Initializes a new instance of the Ascend.VertexInfluence class with given weight and set
		/// of vertices.
		/// </summary>
		/// <param name="weight">
		/// A value between 0.0 and 1.0 (inclusive) specifying the weight associated with this
		/// Ascend.VertexInfluence.
		/// </param>
		/// <param name="vertices">
		/// The vertices associated with this Ascend.VertexInfluence.
		/// </param>
		/// <remarks>
		/// For lazy-loaded models, <paramref name="vertices"/> should contain only one vertex. For
		/// non-lazy-loaded models, <paramref name="vertices"/> should contain the affected vertex
		/// and its aliases.
		/// </remarks>
		public VertexInfluence(double weight, List<int> vertices)
		{
			_weight = weight;
			_vertices = vertices;
		}
		#endregion

		#region Private Members
		private double _weight;
		private List<int> _vertices;
		#endregion

		#region Public Properties
		/// <summary>
		/// Gets a read-only collection of vertices associated with this Ascend.VertexInfluence.
		/// </summary>
		public ReadOnlyCollection<int> Vertices
		{
			get
			{
				return _vertices.AsReadOnly();
			}
		}

		/// <summary>
		/// Gets the weight associated with this Ascend.VertexInfluence.
		/// </summary>
		public double Weight
		{
			get
			{
				return _weight;
			}
		}
		#endregion

		#region Public Methods
		/// <summary>
		/// Creates a deep copy of this Ascend.VertexInfluence.
		/// </summary>
		/// <returns>
		/// Returns the deep copy.
		/// </returns>
		public VertexInfluence Clone()
		{
			return new VertexInfluence(Weight, new List<int>(Vertices));
		}
		#endregion
	}
}
